/**
 * 省市县选择
 **/
layui.define(function(exports) {
    var $ = layui.jquery
    obj = {};
    obj.selectCity = function(form,url , id,url_next,id_next) {
        var cityValue = 0;
        $.getJSON(url, function(d) {
            layui.use('layer',function() {
                if(d.code != 0) {
                    layer.msg(d.msg);
                    return false;
                } else {
                    id = '#'+id;
                    var city = d.data;
                    $(id).html('');
                    var i=0;
                    $.each(city, function(key, val) {
                        if(i == 0) cityValue = val.city_id;
                        var option1 = $("<option>").val(val.city_id).text(val.title);
                        $(id).append(option1);
                        i++;
                    });
                    form.render('select');
                }
            });
            if(url_next) {
                url_next += '?city_id='+cityValue;
                obj.selectCity(form ,url_next , id_next);
            }
        });
    }

    //导出本接口
    exports('citySelect' , obj);
});